<template>
  <div >
    <h3>核心课程</h3>
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      unique-opened
    >
      <!--导航循环 -->

      <div v-for="item in courseData" >
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>{{ item.courseGroup.name }}</span>
          </template>
          <div v-for="item in allCourse">
            <el-menu-item index="1-1">{{ item.course.name }} </el-menu-item>
          </div>
        </el-submenu>
      </div>
    </el-menu>
  </div>
</template>
<script type="text/ecmascript-6">
import axios from 'axios';

const url = require(`../config/config`).dev.localurl;
export default {
    name: `sidebar`,
    data() {
        return {
            courseData: ``,
            allCourse: ``,
            uniqueOpened:true
        };
    },
    props: [],
    created() {
        axios({
            url: url + `/getHomepageInfo`,
            method: `get`
        }).then((res) => {
            this.courseData = res.data.data;

            for (let i of this.courseData) {
                this.allCourse = Object.assign(i.keyCourses, i.ordinaryCourse);

            }

        }).catch((res) => {
            console.log(res.message);
        });
    },
    methods: {
        handleOpen() {
        },
        handleClose() {
        }
    }
};
</script>
